#ifndef DRAGDOUBLESPINBOX_H
#define DRAGDOUBLESPINBOX_H


#include <QDoubleSpinBox>

class DragDoubleSpinBox : public QDoubleSpinBox
{
    Q_OBJECT
public:
    explicit DragDoubleSpinBox(QWidget *parent = 0);
    void SetRangeLength(int length);
    void SetCanDragSetValue(bool dragSetValue);
    bool CanDragSetValue(void)const { return m_canDragSetVaule; }
    void setRange(double minimum, double maximum);  //重定义

protected:
    virtual void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
    virtual void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
    virtual bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;

private:
    void SolveScale(void);
    void SolveLeftRightLength(void);
private:
    bool m_isDragging;
    QPoint m_pressedPoint;
    double m_pressedValue;

    int m_rangeLength;
    bool m_canDragSetVaule;

    double m_scale;     //比例关系为  value / px
    int m_leftLength;
    int m_rightLength;
};

#endif // DRAGDOUBLESPINBOX_H
